#include <iostream>

char* getNext(const char* tar)
{
  int tar_size = strlen(tar);
  char* next = (char*)malloc(tar_size * sizeof(char));
  if (next == nullptr) {
    std::cout << "memory error" << std::endl;
    return nullptr;
  }

  next[0] = -1;
  for (int i = 1; i < tar_size; ++i) {
    if (tar[0] == tar[i])
    {}
  }

  return next;
}

int kmpSearch(const char* src, const char* tar)
{
  if (src == nullptr || tar == nullptr) {
    return -1;
  }

  char* next = getNext(tar);
  if (next == nullptr) {
    return -1;
  }

  return -1;
}

int main(int argc, char* argv)
{
  const char* src = "BBC ABCDAB ABCDABCDABDE";
  const char* tar = "ABCDABD";

  std::cout << kmpSearch(src, tar) << std::endl;

  return 0;
}

